package pl.edu.uj.tcs.blef.protocol;

public class RequestRequestFactory implements RequestFactory {

	@Override
	public Request build(Object[] parameters, RequestHandler handler) throws BuildFailedException {
		if(parameters.length != 2) throw new BuildFailedException("Two parameters excepted");
		try{
			String playerNick = (String)parameters[0];
			String playerIp = (String)parameters[1];
			return new JoinRequest("REQUEST "+playerNick + " "+ playerIp, handler);
		} catch(ClassCastException e) { throw new BuildFailedException(e.getMessage()); }
	}

	@Override
	public Request parse(String message, RequestHandler handler) throws ParseFailedException, BuildFailedException {
		// TODO Add parser in client
		return null;
	}

}
